package net.mikoo.seals.api.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import net.mikoo.seals.api.model.ResultType;
import net.mikoo.seals.api.model.schedule.GetScheduleListRequest;
import net.mikoo.seals.api.model.schedule.GetScheduleListResponse;
import net.mikoo.seals.biz.service.NoticeServices;

@Controller
public class ScheduleController {

	private static Logger logger = LoggerFactory.getLogger(ScheduleController.class);
	
	@Autowired
	private NoticeServices scheduleService;
	
	
	@RequestMapping("/schedule/list")
	@ResponseBody
	public GetScheduleListResponse list(GetScheduleListRequest request, HttpServletRequest httpRequest) {
		GetScheduleListResponse result = new GetScheduleListResponse();
		try {
			
//			if(request == null) {
//				throw new IllegalArgumentException("request");
//			}
//			
//			if(request.getPageNo() == null) {
//				request.setPageNo(1);
//			}
//			
//			if(request.getPageSize() == null) {
//				request.setPageSize(5);
//			}
//			
//			Long partyId = PartyUtility.getCurrentPartyId(httpRequest);
//			if(partyId == null) {
//				throw new IllegalArgumentException("partyId");
//			}
//			
//			NoticeStatusEnum status = NoticeStatusEnum.getByCode(request.getStatus());
//			
//			NoticeQuery query = new NoticeQuery();
//			query.setPartyId(partyId);
//			if(status != null) {
//				query.setScheduleStatus(status.getCode());
//			}
//			query.setOffset((request.getPageNo() - 1)*request.getPageSize());
//			query.setPageSize(request.getPageSize());
//			query.setScheduleStatus(NoticeStatusEnum.PENDING.getCode());
//			query.setOrderColumn("create_time");
//			query.setOrderType("asc");
//			PageModel<Notice> pm = scheduleService.getListToPage(query);
//			if(pm != null) {
//				result = GetScheduleListResponse.valueOf(pm);
//			}
			result.setResult(ResultType.SUCCESS.getValue());
		}catch(Exception e) {
			logger.error("", e);
			result.setResult(ResultType.ERROR.getValue());
		}
		return result;
	}
	
}
